package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.ProductBean;
import com.project.mapper.IProductMapper;
import com.project.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;

/**
 * @Author(王思翰)
 * @Description(类的描述)
 * @Date(创建时间) 2021/8/1 12:14
 */
@Service
@Transactional
public class ProductServiceImpl implements IProductService {
    @Autowired
    private IProductMapper mapper;

    @Override
    public PageInfo<ProductBean> findByItem(int pageNo, String name, LocalDate startDate, LocalDate endDate,String status) {
        PageHelper.startPage(pageNo,4);
        System.out.println(status);
        PageInfo<ProductBean> pageInfo=PageInfo.of(mapper.findByItem(name,startDate,endDate,status));
        return pageInfo;
    }

    @Override
    public ProductBean findbById(int id) {
        return mapper.findbById(id);
    }

    @Override
    public void add(ProductBean productBean) {
        mapper.add(productBean);
    }

    @Override
    public void updateOfStatus(int id) {
        mapper.updateOfStatus(id,"下架");
    }

    @Override
    public void updateOfMoney(int id, int money) {
        mapper.updateOfMoney(id,money);
    }
}
